package xyz.scootaloo.code.common

import cn.hutool.core.lang.Assert

/**
 * 基础功能
 *
 * @author flutterdash@qq.com
 * @since 2021/10/7 23:52
 */

fun Any?.log() {
    println(this)
}

fun <T> List<T>.copy(): MutableList<T> =
    ArrayList<T>().apply dest@{
        for (el in this@copy)
            this@dest.add(el)
    }

infix fun Any?.shouldBe(expected: Any?) {
    if (this != expected) {
        val trance = Thread.currentThread().stackTrace
        val stack = trance[trance.size - 2]
        print("${stack.className}.${stack.methodName}(${stack.fileName}:${stack.lineNumber})")
        println(" => get $this, but expect $expected")
    }
}

fun pause() {}

fun <T> swap(a: T, b: T): Pair<T, T> {
    return b to a
}
